<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>注册</title>
  <!-- import CSS -->
  <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
  <style>
    body {
      background: url("img/1.jpg") no-repeat;
      background-size: 100%;
      overflow: scroll;
      overflow-x: hidden;
      overflow-y: hidden;
    }
    #app{
      position: relative;
      left: 560px;
      top: 300px;
    }
      [v-cloak] {
         display: none
     }
  </style>
</head>
<body>
  <div id="app">
      <h1 v-cloak style="font-family:'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif">{{title}}</h1>
    <el-form :model="ruleForm" status-icon  ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="用户名" prop="username">
          <el-input type="input" v-model="ruleForm.username" autocomplete="off" style="width: 220px;" ></el-input>
        </el-form-item>
      <el-form-item label="密码" prop="pass">
          <el-input type="input" v-model="ruleForm.password" autocomplete="off" style="width: 220px;" ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm" v-cloak>提交</el-button>
          <el-button @click="resetForm('ruleForm')" v-cloak>重置</el-button>
          <el-button type="primary" @click="save" v-cloak>去登录</el-button>
        </el-form-item>
      </el-form>
  </div>
</body>
  <!-- import Vue before Element -->
  <script src="https://unpkg.com/vue/dist/vue.js"></script>
  <!-- import JavaScript -->
  <script src="https://unpkg.com/element-ui/lib/index.js"></script>
  <script src="lib/axios.min.js"></script>
<script src="lib/myconfig.js"></script>
  <script>
    new Vue({
      el: '#app',
      data: function() {

        var validatePass = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入密码'));
        } else {
          if (this.ruleForm.checkPass !== '') {
            this.$refs.ruleForm.validateField('checkPass');
          }
          callback();
        }
      };
      var validatePass2 = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请再次输入密码'));
        } else if (value !== this.ruleForm.pass) {
          callback(new Error('两次输入密码不一致!'));
        } else {
          callback();
        }
        };
        return { 
          title:'高校人力资源管理系统',
          ruleForm: {
          username: '',
          password: ''
        },
        }
      },
      methods:{
        submitForm() {
        axios.post(
          myurl + "/staff/insert", this.ruleForm
        ).then(function (res) {
          var resData = res.data;
          if (resData !== "") {
            console.log("me success");
            console.log(resData);
            location.href = "login.html";
          } else {
            console.log("me fail");
            console.log(resData);
          }
          console.log(res);
        });
      },
      save(){
          location.href="login.html";
        },
    }
    })
  </script>
</html>